package com.yetm.springbootdemo.controller;

import com.yetm.springbootdemo.entity.SMSCode;
import com.yetm.springbootdemo.service.SMSCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/sms")
public class SMSCodeController {

    @Autowired
    private SMSCodeService smsCodeService;

    @GetMapping("{phone}")
    public String getCode(@PathVariable("phone") String phone) {
        String smsCode = smsCodeService.sendSMSCode(phone);
        return smsCode;
    }

    @PostMapping
    public Boolean checkCode(SMSCode smsCode) {
        Boolean aBoolean = smsCodeService.checkCode(smsCode);
        return aBoolean;
    }

}
